package org.emet.service;
import org.emet.dao.InfraccionLogDao;
import org.emet.entity.biz.VehInfraccionLog;
import org.emet.jee.BusinessException;
import org.emet.jee.core.dao.Page;
import org.emet.service.dto.InfraccionLogCriteria;
import org.hibernate.ObjectNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
@RemotingDestination
public class InfraccionLogService {
@Autowired
private InfraccionLogDao infraccionLogDao;
private static Logger logger = LoggerFactory.getLogger(InfraccionLogService.class);
public void save(VehInfraccionLog entity) {
try {
infraccionLogDao.save(entity);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new BusinessException("发生异常!");
}
}
	@Transactional(readOnly = true)
public VehInfraccionLog getInfraccionLog(Long id) {
try {
return infraccionLogDao.get(id);
} catch (ObjectNotFoundException e) {
logger.error(e.getMessage(), e);
throw new BusinessException("发生异常!");
}
}
public void del(Long... ids) {
for (Long id : ids) {
if (notExist(id)) {
continue;
}
try {
infraccionLogDao.delete(id);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new BusinessException("发生异常!");
}
}
}
private boolean notExist(Long id) {
return getInfraccionLog(id) == null;
}
	@Transactional(readOnly = true)
public Page<VehInfraccionLog> search(Page<VehInfraccionLog> page, InfraccionLogCriteria criteria) {
try {return 
infraccionLogDao.search(page, criteria);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new BusinessException("发生异常!");
}
}
}
